package com.easyedu.helper.dao;

import com.easyedu.core.entity.po.Institute;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;


/**
 * @author lmr
 **/
@Mapper
public interface InstituteDao {

    /**
     * 功能描述:新增学院专业信息
     *
     * @param institute 1 学院 institute表 Persistant Object
     * @return : java.lang.Integer
     **/
    @Insert("insert into institute(institute_id, institute_name, department_id, department_name) VALUES (#{instituteId},#{instituteName},#{departmentId},#{departmentName})")
    Integer createInstitute(Institute institute);

    /**
     * 功能描述:删除学院和专业信息
     *
     * @param institute 1 学院 institute表 Persistant Object
     * @return : java.lang.Integer
     **/
    @Delete("delete from institute where department_id = #{departmentId} AND institute_id = #{instituteId}")
    Integer deleteInstitute(Institute institute);

    /**
     * 功能描述:通过学院id查询学院名称
     *
     * @param instituteId 1 学院id
     * @return : com.easyedu.api.entity.DO.Institute
     **/
    @Select("select institute_id,institute_name from institute where institute_id = #{instituteId} group by institute_id,institute_name")
    Institute getInstituteById(long instituteId);

    /**
     * 功能描述: 查询专业信息
     *
     * @param openInstituteId  1 专业id
     * @param openDepartmentId 2  专业名称
     * @return : com.easyedu.api.entity.DO.Institute
     **/
    @Select("select * from institute where institute_id = #{openInstituteId} AND department_id = #{openDepartmentId}")
    Institute getDepartmentById(long openInstituteId, long openDepartmentId);

    /**
     * 功能描述: 查询学院及专业信息
     *
     * @return : java.util.List<com.easyedu.api.entity.DO.Institute>
     **/
    @Select("select  * from institute")
    List<Institute> getInstitute();
}
